package org.tyq.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Service;
import org.tyq.service.BaseService;

@Service
public class BaseServiceImpl extends SqlSessionDaoSupport implements BaseService{

	@Resource(name="SqlSessionFactiony")
	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory){
		super.setSqlSessionFactory(sqlSessionFactory);
	}
	
	@Override
	public <T> T get(String nameSpase, Object params) {
		return getSqlSession().selectOne(nameSpase, params);
	}

	@Override
	public <T> T get(String nameSpase) {
		return getSqlSession().selectOne(nameSpase);
	}
	
	@Override
	public <T> List<T> getList(String nameSpase) {
		return getSqlSession().selectList(nameSpase);
	}

	@Override
	public <T> List<T> getList(String nameSpase, Object params) {
		return getSqlSession().selectList(nameSpase,params);
	}
	
	public int update(String nameSpase){
		return getSqlSession().update(nameSpase);
	}
	
	public int update(String nameSpase, Object params){
		return getSqlSession().update(nameSpase,params);
	}
	
	public int delete(String nameSpase){
		return getSqlSession().delete(nameSpase);
	}
	
	public int delete(String nameSpase, Object params){
		return getSqlSession().delete(nameSpase, params);
	}
	
	public int insert(String nameSpase){
		return getSqlSession().insert(nameSpase);
	}
	
	public int insert(String nameSpase, Object params){
		return getSqlSession().insert(nameSpase, params);
	}

}
